import { api } from "src/boot/axios";

export function createFile(formData) {
  return api({
    url: "/files/",
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data", // 确保设置为 multipart/form-data
    },
  });
}

export function deleteFile(file_id) {
  return api({
    url: `/file/${file_id}/`,
    method: "delete",
  });
}

export function updateFile(formData) {
  return api({
    url: "/updateFile/",
    method: "post",
    data: formData,
    headers: {
      "Content-Type": "multipart/form-data", // 确保设置为 multipart/form-data
    },
  });
}

export function getFiles(project_id) {
  return api({
    url: `/projects/${project_id}/files/`,
    method: "get",
    responseType: "blob",
  });
}

export function createProject(formData) {
  return api({
    url: "/projects/",
    method: "post",
    data: formData,
  });
}

export function getProjects(userId) {
  return api({
    url: `/projects?userId=${userId}`, // 将 userId 添加到查询参数
    method: "get",
  });
}

export function createModel(formData) {
  return api({
    url: "/model/",
    method: "post",
    data: formData,
  });
}

export function getModel(file_id) {
  return api({
    url: `/model/${file_id}/`,
    method: "get",
  });
}
// 创建参数集
export function createDataset(data) {
  return api({
    url: `datasets`,
    method: "post",
    data: data,
  });
}

// 获取参数集
export function getDataset(file_id) {
  return api({
    url: `/datasets/${file_id}/`,
    method: "get",
  });
}

export function getResult(data) {
  return api({
    url: `/get_result/`,
    method: "post",
    data: data,
  });
}

export function createDrawing(data) {
  return api({
    url: "/drawing",
    method: "post",
    data: data,
  });
}


export function getDrawData(data) {
  return api({
    url: "/draw_data",
    method: "post",
    data: data,
  });
}

// 添加删除项目的接口
export function deleteProject(projectId) {
  return api({
    url: `/project/${projectId}/`,
    method: 'delete'
  });
}
